//
// C++ Implementation: thread
//
// Description: 
//
//
// Author:  <muse2k@mail.ru>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//

#include "thread.h"
#include <qobject.h>
#include <qprocess.h>




myprocess::myprocess() {

   qDebug("init");
   QPtrList<QProcess>  list;
   
  
}


myprocess::~myprocess() {

  qDebug("CLASS - Process terminated");

}



void myprocess::deleteAllProcesses(){
   
   qDebug("CLASS - deleteAllProcesses");

}



int myprocess::createProcess(const QString& str){
   
   
   qDebug("CLASS - createProcess");
   QProcess *c = new QProcess();
   list.append(c);
   int a = 0;
        
   connect(c, SIGNAL(readyReadStdout()), this, SLOT(out()));
   connect(c, SIGNAL(readyReadStderr()),  this, SLOT(out()));
   connect(c, SIGNAL(processExited()),  this, SLOT(endProcess()));
   
   
   QStringList list = QStringList::split(" ", str);
   QStringList::iterator it;
   
   c->clearArguments();             
   for (it = list.begin(); it != list.end(); ++it) {
                 c->addArgument(*it);
   }
    c->start();
    a = 0;
	c->processIdentifier();
//     qDebug("a %d", a);
    
    return a;
};



void myprocess::deleteProcess(){
   qDebug("CLASS - deleteProcess");
};


 
 void myprocess::runProcess(){
    qDebug("CLASS - runProcess");
 };



 void myprocess::stopProcess(){
    qDebug("CLASS - stopProcess");
 };
 
 
 void myprocess::out(){
//     qDebug("aa");
    
    QPtrListIterator<QProcess> it(list);
    QProcess* w;

    for (; w = it.current() ; ++it){
//        (*it)->pingall();
//        qDebug( (*it)->readStdout());
    }
 }
 
 
 void myprocess::endProcess(){
    qDebug("CLASS - ENDPRO");
 };
 
 